package com.jdbcpool;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

public class PoolLog {
	public static int ALL_LEVEL=3;
	public static int DEBUG_LEVEL=2;
	public static int WARING_LEVEL=1;
	public static int ERROR_LEVEL=0;
	
	
	private JdbcPoolDataSource ds;
	static SimpleDateFormat tempDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
	
	public JdbcPoolDataSource getDs() {
		return ds;
	}
	public void setDs(JdbcPoolDataSource ds) {
		this.ds = ds;
	}
	PoolLog(JdbcPoolDataSource ds) {
		setDs(ds);
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}
	public void log(String message,int level) {
		if (ds.getLogLevelValue()>=level) {
			String datetime = tempDate.format(new java.util.Date());
			StringBuilder sb=new StringBuilder();
			sb.append("[").append(datetime).append("]");
			if (ds.getName()!=null) {
				sb.append("[").append(ds.getName()).append("]");
			}
			sb.append(message);
			System.out.println(sb.toString());
		}
	}

}
